﻿#include "TradeBlocker.h"
#include <thread>

TradeBlocker::TradeBlocker(int pBlockSeconds)
{
	m_blockTimes = pBlockSeconds * 2;
}

TradeBlocker::~TradeBlocker()
{
}

void TradeBlocker::BlockCTP()
{

	for (int i = 0; i < m_blockTimes; ++i)
	{
		std::this_thread::sleep_for(std::chrono::milliseconds(500));
	}
}

void TradeBlocker::StopBlock()
{
	m_blockTimes = 0;
}

BlockerSmart Blocker::Create(int pBlockSeconds)
{
	BlockerSmart blocker(new TradeBlocker(pBlockSeconds));
	return blocker;
}

void Blocker::Stop(BlockerSmart pBlocker)
{
	if (pBlocker.get() == nullptr)
	{
		return;
	}
	pBlocker->StopBlock();
}
